﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Linq;
using WPFExcelReport.Helpers;
using System.Windows.Input;
using System.Windows.Controls;
namespace WPFExcelReport
{
    /// <summary>
    /// 专用于布卷剪布
    /// </summary>
    public partial class TWB10
    { 
 
        public TWB10()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWBBST();
            this.DataContext = MV;
            InitializeComponent(); 
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                RWAUF = "";
            }
            else
            {
                RWAUF = TMV.WBBRWKRS + TMV.WBBRWLFD;
            }
        }

        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            string skt = STKNR;
            STKNR = "";
            STKNR = skt;
            base.QueryCommand(sender, e);
        }
        public override void NewCommand(object sender, System.Windows.RoutedEventArgs e)
        {
           
            if (dwMaster == null)
                return;
            if (dwMaster["WBBAUFLFD"].ToString() != "000000")
            {
                MessageBox.Show("已经被留位，需要先取消留位");
                return;
            }
            
            TMV.CUTWB(dwMaster, CMTR, RUNID);
            RWAUF = ""; 
            vwMaster.View.MoveCurrentToFirst();
            base.NewCommand(sender, e);
        }  
        public override void OnSTKNRChg(string value)
        {
            if (value.Length == 0)
                return; 
            if (!IsLoaded)
                return;
            dwData = TBMain.NewRow();
            dwData["WBBMANDANT"] = app.Mandant;
            dwData["WBBSTKNR"] = value;
            SResult = TMV.QWB13(dwData);
            MergeData(SResult, true); 
            base.OnSTKNRChg(value);
        }
    }
}
